package com.quanyue.haircut.shop.mapper;

import com.quanyue.haircut.domain.entity.UserIntegral;
import com.quanyue.haircut.shop.dto.IntegralOrderDetail;
import com.vhuomai.mybatis.mapper.auto.AutoMapper;
import com.vhuomai.mybatis.mapper.page.Page;
import com.vhuomai.mybatis.mapper.page.PageRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface IntegralMapper extends AutoMapper <UserIntegral, Integer> {
    UserIntegral findByUserAndShop(@Param("userId") Integer userId, @Param("shopId") Integer shopId);

    @Select("select c.integral_count, u.nick_name, u.head_image, p.product_name, p.product_image "
            + "from qy_integral_convert c "
            + "left join qy_user u on u.id = c.user_id "
            + "left join qy_integral_product p on p.id = c.product_id "
            + "where c.shop_id = #{shopId}")
    Page <IntegralOrderDetail> findByOrderDetail(@Param("shopId") Integer shopId, @Param("request") PageRequest request);
}
